package com.itranswarp.learnjava;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Learn Java from https://www.liaoxuefeng.com/
 * 
 * @author liaoxuefeng
 */
public class Main {

	public static void main(String[] args) {
		String[] array = new String[] { "apple", "Orange", "banana", "Lemon" };
		// 请使用忽略大小写排序，并改写为Lambda表达式:
		Arrays.sort(array, new Comparator<>() {
			@Override
			public int compare(String o1, String o2) {
				return o1.compareTo(o2);
			}
		});
		Arrays.sort(array,((o1, o2) -> o1.toLowerCase().compareTo(o2.toLowerCase())));
		System.out.println(String.join(", ", array));

		List<String> names = Arrays.asList(array);
		List<Person> persons = names.stream().map(name -> new Person(name)).collect(Collectors.toList());

	}
}

class Person {
	String name;
	public Person(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "Person{" +
				"name='" + name + '\'' +
				'}';
	}
}
